<?php
require_once '../funciones.php';
$con        = con_caweb();
$facturasistema = $_REQUEST['facturasistema'];
$idabonos       = $_REQUEST['idabono'];
$soporte        =$_SESSION['caweb']['soporte'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15">
        <title>Discrepancias Identificador Vs Factua - Abonos</title>
    </head>
    <body>
        <center>
            <table border="1">
            <caption>DIFERENCIAS ENTRE LA FACTURACION Y EL IDENTIFICADOR</caption>
            <tr >
                <th>Procedencia</th>
                <th>Sucursal</th>
                <th>Factura</th>
                <th>Ajuste</th>
                <th>Estado Cartera</th>
                <th>Cliente</th>
                <th>Base</th>
                <th>Iva</th>
                <th>Total</th>
                <th>Rete Fuente</th>
                <th>Rete Iva</th>
                <th>Rete Ica</th>
                <th>Otros</th>
                <th>Cuadre</th>
            </tr>
            <tr style="background: #BDBDBD;font-weight: bolder">
            <?php
            $sql = "select ajuste,estadocartera,fac.sucursal,fac.factura,fac.base,fac.iva,fac.total,fac.retefuente,fac.reteiva,fac.reteica,fac.otros,fac.cuadre,man.name from cabeceras_fac fac
                    inner join clientes man on man.nit = fac.cliente where fac.facturasistema = $facturasistema";
            $result = mysql_query($sql, $con) or die("Error SQL 2".  mysql_error().$sql);
            $cliente = mysql_result($result, 0,"name");
            echo "<td>Facturacion</td>";
            echo "<td>".  mysql_result($result, 0,"sucursal")."</td>";
            echo "<td>".  mysql_result($result, 0,"factura")."</td>";
            echo "<td>".  mysql_result($result, 0,"ajuste")."</td>";
            echo "<td>".  mysql_result($result, 0,"estadocartera")."</td>";
            echo "<td>".  mysql_result($result, 0,"name")."</td>";
            echo "<td>".  number_format(mysql_result($result, 0,"base"),0, ',', '.')."</td>";
            echo "<td>".  number_format(mysql_result($result, 0,"iva"),0, ',', '.')."</td>";
            echo "<td>".  number_format(mysql_result($result, 0,"total"),0, ',', '.')."</td>";
            echo "<td>".  number_format(mysql_result($result, 0,"retefuente"),0, ',', '.')."</td>";
            echo "<td>".  number_format(mysql_result($result, 0,"reteiva"),0, ',', '.')."</td>";
            echo "<td>".  number_format(mysql_result($result, 0,"reteica"),0, ',', '.')."</td>";
            echo "<td>".  number_format(mysql_result($result, 0,"otros"),0, ',', '.')."</td>";
            echo "<td>".  number_format(mysql_result($result, 0,"cuadre"),0, ',', '.')."</td>";
            ?>
            </tr>
            <tr>
                <?php
            $sql = "select det.estadocartera,det.ajuste,det.rteFuente,det.rteIva,det.rteIca,det.otros,det.cuadre from detallesabonosId det where det.idabonos = $idabonos and det.facturasistema = $facturasistema";
            $result1 = mysql_query($sql, $con) or die("Error SQL 2".  mysql_error().$sql);
            echo "<td>Identificador</td>";
            echo "<td>".  mysql_result($result, 0,"sucursal")."</td>";
            echo "<td>".  mysql_result($result, 0,"factura")."</td>";
            echo "<td>".  mysql_result($result1, 0,"ajuste")."</td>";
            echo "<td>".  mysql_result($result1, 0,"estadocartera")."</td>";
            echo "<td>".  mysql_result($result, 0,"name")."</td>";
            echo "<td>".  number_format(mysql_result($result, 0,"base"),0, ',', '.')."</td>";
            echo "<td>".  number_format(mysql_result($result, 0,"iva"),0, ',', '.')."</td>";
            echo "<td>".  number_format(mysql_result($result, 0,"total"),0, ',', '.')."</td>";
            echo "<td>".  number_format(mysql_result($result1, 0,"rteFuente"),0, ',', '.')."</td>";
            echo "<td>".  number_format(mysql_result($result1, 0,"rteIva"),0, ',', '.')."</td>";
            echo "<td>".  number_format(mysql_result($result1, 0,"rteIca"),0, ',', '.')."</td>";
            echo "<td>".  number_format(mysql_result($result1, 0,"otros"),0, ',', '.')."</td>";
            echo "<td>".  number_format(mysql_result($result1, 0,"cuadre"),0, ',', '.')."</td>";
                ?>
            </tr>
        </table>
        <input type="button" value="Cerrar" onclick="window.close()" />
    </center>
        <?php
        // put your code here
        ?>
    </body>
</html>
